<template>
  <div class="view-wrapper">
    <div class="head">
      <el-form :model="queryParams" ref="queryForm" :inline="true">
         <el-form-item label="券码状态：" prop="couponType">
          <el-select v-model="queryParams.couponType" placeholder="请选择" style="width: 240px;">
            <el-option v-for="item in statusList" :key="item.id" :label="item.value" :value="item.id">
            </el-option>
          </el-select>
        </el-form-item>       
        <el-form-item label="核销时间：">
          <el-date-picker clearable v-model="date" type="daterange" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="changeTime" placeholder="请选择">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">查询</el-button>
          <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="listBox">
      <div class="listBox_head" style="margin: 0 0 20px">
        <div class="div_title">
          {{ name }}
        </div>

        <el-button type="primary" @click="writeOffUpLoad">修正导入数据</el-button>
      </div>
      <el-table v-loading="loading" ref="multipleTable" :data="tabList" stripe border tooltip-effect="dark"
        style="width: 100%">
        <el-table-column label="序号" align="center" type="index" width="64px" />
        <el-table-column label="核销时间" align="center" prop="verifyTime"></el-table-column>
        <el-table-column label="券码" align="center" prop="couponCode"></el-table-column>
        <el-table-column label="核销ID" align="center" prop="verifyId"  width="160px"></el-table-column>
        <el-table-column label="核销渠道" align="center" prop="verifyChannel"></el-table-column>
        <el-table-column label="核销场景" align="center" prop="verifyScene"></el-table-column>
        <el-table-column label="核销人昵称" align="center" prop="verifierNickname"></el-table-column>
        <el-table-column label="核销人账号" align="center" prop="verifierAccount" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="核销人ID" align="center" prop="verifierId" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="适用门店类型" align="center" prop="applyShopType"></el-table-column>
        <el-table-column label="核销门店" align="center" prop="verifyShop"></el-table-column>
        <el-table-column label="当前关联商场" align="center" prop="associationShop"></el-table-column>
        <el-table-column label="当前关联商场ID" align="center" prop="associationShopId"></el-table-column>
        <el-table-column label="核销门店名称备注" align="center" prop="verifyShopRemark"></el-table-column>
        <el-table-column label="核销门店ID" align="center" prop="verifyShopId" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="核销门店编号备注" align="center" prop="verifyShopNumberRemark"></el-table-column>
        <el-table-column label="核销门店城市" align="center" prop="verifyShopCity"></el-table-column>
        <el-table-column label="核销门店省份" align="center" prop="verifyShopProvince"></el-table-column>
        <el-table-column label="商品名称" align="center" prop="productName"></el-table-column>
        <el-table-column label="商品类型" align="center" prop="productType"></el-table-column>
        <el-table-column label="商品ID" align="center" prop="productId" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="商品类目" align="center" prop="productCategories"  width="160px"></el-table-column>
        <el-table-column label="商品归属" align="center" prop="productOwnership"></el-table-column>
        <el-table-column label="商品归属商户" align="center" prop="productOwnershipMerchant"></el-table-column>
        <el-table-column label="商品归属商户ID" align="center" prop="productOwnershipMerchantId"  :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="消费者UID" align="center" prop="consumerUid" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="订单支付时间" align="center" prop="payTime"></el-table-column>
        <el-table-column label="订单编号" align="center" prop="orderNo"></el-table-column>
        <el-table-column label="订单标签" align="center" prop="orderLabel"></el-table-column>
        <el-table-column label="券码状态" align="center" prop="couponType"></el-table-column>
        <el-table-column label="成交渠道" align="center" prop="dealChannels" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="订单实收" align="center" prop="orderReceived"></el-table-column>
        <el-table-column label="各类服务费率基数" align="center" prop="variousServiceRateBases"></el-table-column>
        <el-table-column label="券售卖金额" align="center" prop="couponSalesAmount"></el-table-column>
        <el-table-column label="商家补贴" align="center" prop="merchantSubsidies"></el-table-column>
        <el-table-column label="商家补贴优惠明细" align="center" prop="merchantSubsidiesDiscountDetails" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column label="代金券核销面值" align="center" prop="vouchersVerifyPrice"></el-table-column>
        <el-table-column label="用户实付" align="center" prop="actualPayment"></el-table-column>
        <el-table-column label="抖音支付优惠" align="center" prop="tiktokPaymentDiscount"></el-table-column>
        <el-table-column label="平台补贴" align="center" prop="platformSubsidies"></el-table-column>
        <el-table-column label="平台补贴优惠明细" align="center" prop="platformSubsidiesDiscountDetails"></el-table-column>
        <el-table-column label="软件服务费" align="center" prop="softwareServiceFee"></el-table-column>
        <el-table-column label="软件服务费费率" align="center" prop="softwareServiceFeeRate"></el-table-column>
        <el-table-column label="软件服务费费率特殊情况说明" align="center" prop="softwareServiceFeeExplain"></el-table-column>
        <el-table-column label="支付手续费（已含在软件服务费中）" align="center" prop="payFee"></el-table-column>
        <el-table-column label="支付手续费费率" align="center" prop="payFeeRadio"></el-table-column>
        <el-table-column label="达人佣金" align="center" prop="expertCommission"></el-table-column>
        <el-table-column label="达人佣金比例" align="center" prop="expertCommissionRatio"></el-table-column>
        <el-table-column label="达人昵称" align="center" prop="expertNickname"></el-table-column>      
        <el-table-column label="达人抖音号" align="center" prop="tiktokNumber"></el-table-column>      
        <el-table-column label="达人uid" align="center" prop="expertUid"  :show-overflow-tooltip="true"></el-table-column>      
        <el-table-column label="撮合经纪服务费" align="center" prop="matchingBrokerageServiceFee"></el-table-column>      
        <el-table-column label="服务商佣金" align="center" prop="serviceProviderCommission"></el-table-column>      
        <el-table-column label="服务商佣金比例" align="center" prop="serviceProviderCommissionRatio"></el-table-column>      
        <el-table-column label="服务商名称" align="center" prop="serviceProviderName"  :show-overflow-tooltip="true"></el-table-column>      
        <el-table-column label="保险费用" align="center" prop="insuranceCosts"></el-table-column>      
        <el-table-column label="商家应得" align="center" prop="merchantsDeserve"></el-table-column>      
        <el-table-column label="提现状态" align="center" prop="withdrawStatus"></el-table-column>       
        <el-table-column label="分账时间" align="center" prop="divideAccountsTime"></el-table-column>     
        <el-table-column label="提现金额" align="center" prop="withdrawMoney"></el-table-column>     
        <el-table-column label="提现发起时间" align="center" prop="withdrawStartTime"></el-table-column>     
        <el-table-column label="提现完成时间" align="center" prop="withdrawDoneTime"></el-table-column>     
        <el-table-column label="收款主体" align="center" prop="payee"></el-table-column>     
        <el-table-column label="收款门店" align="center" prop="receivingShop"></el-table-column>     
        <el-table-column label="收款账号" align="center" prop="receivingAccount"></el-table-column>     
        <el-table-column label="店员昵称" align="center" prop="shopAssistantNickname"></el-table-column>     
        <el-table-column label="店员抖音号" align="center" prop="shopStaffTiktokNumber"></el-table-column>     
        <el-table-column label="店员UID" align="center" prop="shopStaffUid"  :show-overflow-tooltip="true"></el-table-column>   
        <el-table-column label="店员激励金额" align="center" prop="incentiveAmount"></el-table-column>   
        <el-table-column label="店员激励金额比例" align="center" prop="incentiveAmountRate"></el-table-column>  
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList"></pagination>
    </div>

    <!-- 直播结果弹窗 -->
    <Dialog v-if="dialogVisible" :id="dialogId" :name="name" :pathType="pathType" :visible.sync="dialogVisible"
      @success="_handleSuccess">
    </Dialog>
  </div>
</template>

<script>
import {
  verifyList,
} from "@/api/customer/serviceData";
import {
  responsibleSelect,
} from "@/api/customer/customerFile";
import Dialog from "./components/Dialog";
import ExportExcelButton from "@/components/ExportExcelButton/index";
export default {
  name: "",
  components: {
    Dialog,
    ExportExcelButton
  },
  data() {
    return {
      dialogId: '',
      dialogVisible: false,
      watchVisible: false,
      // 遮罩层
      loading: false,
      // 导出遮罩层
      // 总条数
      total: 0,
      //表格数据
      tabList: [],
      pathType: 'add',
      date: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        beginTime: '',
        endTime: '',
        clientId: '',
        couponType: '',
      },
      shopType: "",
      statusList: [
        { id: '', value: '全部' },
        { id: '已核销', value: '已核销' },
        { id: '已撤销核销', value: '已撤销核销' },
      ],
    };
  },
  computed: {

  },
  created() {    
    this.queryParams.clientId = this.$route.query.id
    this.name =  this.$route.query.name
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      verifyList(this.queryParams).then(response => {       
        this.tabList = response.result.records;
        this.tabList = this.tabList.map(item => {
              Object.keys(item).forEach(key => {
                if (item[key] === '') {
                  item[key] = '-'
                }
              })
              return item
            })
        this.total = response.result.total;
        this.loading = false;
      });
    },
    //处理时间
    changeTime(e) {
      this.queryParams.beginTime = e[0]
      this.queryParams.endTime = e[1]
    },
    // 表单重置
    reset() {
      this.date = []
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        beginTime: '',
        endTime: '',
        couponType: '',
        clientId:this.$route.query.id
      };
      this.resetForm("queryParams");
      this.handleQuery()
    },
    writeOffUpLoad() {
      this.dialogId = this.queryParams.clientId
      this.dialogVisible = true;
      this.pathType = 'write'
    },
    //售卖明细
    salesClick(row) {
    },
    //核销记录
    writeOffClick(row) {
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.resetForm("queryForm");
      this.reset();
    },
    _handleSuccess(e) {
      //成功回调
      this.resetQuery()
    },
  }
};

</script>
<style scoped>
.head {
  box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
  background-color: #fff;
  border-radius: 8px;
  padding: 20px 20px 0;
}

.listBox {
  box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
  background-color: #fff;
  border-radius: 8px;
  padding: 20px 20px;
  margin-top: 10px;
}

.listBox_head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.img_box {
  width: 100px;
  height: 80px;
  border-radius: 4px;
}

.contentTitle {
  width: 100%;
  display: flex;
}

.div_title {
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
}
</style>